package com.htsk.city.services.wechat.controller;

import com.htsk.city.services.core.domain.OrderReview;
import com.htsk.city.services.core.domain.WxUser;
import com.htsk.city.services.core.entity.R;
import com.htsk.city.services.wechat.annotation.GetUserInfo;
import com.htsk.city.services.wechat.params.OrderQueryParam;
import com.htsk.city.services.wechat.params.PostQueryParam;
import com.htsk.city.services.wechat.service.OrderService;
import com.htsk.city.services.wechat.vo.OrderAddVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {

        @Resource
        private OrderService orderService;
        /**
         * 用户创建订单
         */
        @PostMapping("/add")
        public R add(@GetUserInfo WxUser wxUser, @RequestBody OrderAddVo orderVo) {

            return orderService.add(wxUser, orderVo);
        }

        /**
         * 师傅接单
         */
        @PostMapping("/accept")
        public R accept(@GetUserInfo WxUser wxUser, Long orderId) {
                return orderService.accept(wxUser, orderId);
        }

        /**
         * 师傅拒绝接单
         */
        @PostMapping("/refuse")
        public R refuse(@GetUserInfo WxUser wxUser, Long orderId) {
                return orderService.refuse(wxUser, orderId);
        }

        /**
         * 用户取消订单
         */
        @PostMapping("/cancel")
        public R cancel(@GetUserInfo WxUser wxUser, Long orderId) {
                return orderService.cancel(wxUser, orderId);
        }

        /**
         * 根据状态,分页获取我的订单列表
         */
        @PostMapping("/queryMy")
        public R queryMy(@GetUserInfo WxUser wxUser,@RequestBody OrderQueryParam orderQueryParam) {
                return orderService.queryMy(wxUser, orderQueryParam, false);
        }

        /**
         * 查询订单详情
         */
        @PostMapping("/detail")
        public R detail(Long orderId) {
                return orderService.detail(orderId);
        }


        /**
         * 根据状态,分页获取我的接单列表
         */
        @PostMapping("/queryMyAccepted")
        public R queryMyAccepted(@GetUserInfo WxUser wxUser,@RequestBody OrderQueryParam orderQueryParam) {
                return orderService.queryMy(wxUser, orderQueryParam, true);
        }

        /**
         * 添加订单评价
         */
        @PostMapping("/addReview")
        public R addReview(@GetUserInfo WxUser wxUser,@RequestBody OrderReview orderReview) {
                return orderService.addReview(wxUser, orderReview);
        }




}
